 <!DOCTYPE html>
<html>
<head>
<script src="../js/jquery-1.11.1.min.js"></script>
<script src="../js/inserimentoCaratteristiche.js"></script>
<script src="../js/GestioneCookie.js"></script>
<link href="../css/indexBootCSS.css" rel="stylesheet" type="text/css">

<meta charset="ISO-8859-1">
<title>Login</title>
<style type="text/css">
</style>
<!--META -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- META -->
<!-- CSS -->
<link href="../css/bootstrap.min.css" rel="stylesheet" media="screen">
<!-- CSS -->

<!-- Java Script per la gestione Registrazione -->
<script src="../js/RegistrazioneJavaScript.js"></script>

<!-- Java Script Bootstrap -->
<script src="../js/RegistrazioneBoot.js"></script>

<!-- Css della form di registrazione bootstrap -->
<link href="../css/RegistrazioneCSS.css" rel="stylesheet"type="text/css">


</head>
<body>
	<div class="row affix-row">
		<div class="col-sm-3 col-md-2 affix-sidebar">
			<div class="sidebar-nav">
				<div class="navbar navbar-default" role="navigation">
					<div class="navbar-header">
						<button type="button" class="navbar-toggle" data-toggle="collapse"
							data-target=".sidebar-navbar-collapse">
							<span class="sr-only">Toggle navigation</span> <span
								class="icon-bar"></span> <span class="icon-bar"></span> <span
								class="icon-bar"></span>
						</button>
						<span class="visible-xs navbar-brand">Sidebar menu</span>
					</div>
					<div class="navbar-collapse collapse sidebar-navbar-collapse">
						<ul class="nav navbar-nav" id="sidenav01">
							<li class="active"><a href="indexBoot.html"
								data-toggle="collapse" data-target="#toggleDemo0"
								data-parent="#sidenav01" class="collapsed">
									<div class="logo">
										<img src="logo.jpg" alt="logo">
									</div>
							</a></li>

							<li><a href="indexBoot.html"> <span
									class="glyphicon glyphicon-home"></span> HomePage
							</a></li>

							<li><a href="indexBoot.html" class="collapsed"> <span
									class="glyphicon glyphicon-inbox"></span> Chi Siamo
							</a></li>

							<li>
								<!-- sottomenu --> <a href="#" data-toggle="collapse"
								data-target="#toggleDemo" data-parent="#sidenav01"
								class="collapsed"> <span class="glyphicon glyphicon-wrench"></span>
									Assemblaggio <span class="caret pull-right"></span>
							</a>
								<div class="collapse" id="toggleDemo" style="height: 0px;">
									<ul class="nav nav-list">
										<li><a href="Automatico.html">Automatico</a></li>
										<li><a href="ManualeAssistito.html">Manuale Assistito</a></li>
									</ul>
								</div>
							</li>

							<li><a href="Contatti.html"><span
									class="glyphicon glyphicon-phone"></span> Contatti</a></li>
							<li><a href="Login.html"><span
									class="glyphicon glyphicon-user"></span> Login</a></li>
						</ul>
					</div>
					<!--/.nav-collapse -->
				</div>
			</div>
		</div>
		<div class="col-sm-9 col-md-10 affix-content">
			<div class="container">

				<div class="page-header">
					<div id="logged">
						<table id="logged">
							<tr id="info">
								<td id="user"></td>
								<td id="pagina_personale"></td>
								<td id="logout"></td>
							</tr>
						</table>
					</div>
					<h3>
						<script>
							document.write(document.title)
						</script>
					</h3>
				</div>

<!--///////////  CODICE RIGURADANTE IL LOGIN ////////////////////////////////-->

				<div class="container">
					<div id="loginbox" style="margin-top: 50px;"
						class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
						<div class="panel panel-info">
							<div class="panel-heading">
								<div class="panel-title">Accedi</div>
								<div
									style="float: right; font-size: 80%; position: relative; top: -10px">
									
								</div>
							</div>

							<div style="padding-top: 30px" class="panel-body">

								<div style="display: none" id="login-alert"
									class="alert alert-danger col-sm-12"></div>

								<form id="loginform" class="form-horizontal" role="form">

									<div style="margin-bottom: 25px" class="input-group">
										<span class="input-group-addon"><i
											class="glyphicon glyphicon-user"></i></span> <input
											id="login-username" type="text" class="form-control"
											name="username" value="" placeholder="username">
									</div>

									<div style="margin-bottom: 25px" class="input-group">
										<span class="input-group-addon"><i
											class="glyphicon glyphicon-lock"></i></span> <input
											id="login-password" type="password" class="form-control"
											name="password" placeholder="password">
									</div>



									<div class="input-group">
										
									</div>


									<div style="margin-top: 10px" class="form-group">
										<!-- Button -->

										<div class="col-sm-12 controls">
											<a id="btn-login" class="btn btn-success">Login</a>

										<script>
										function getURIParameter(param, asArray) {
										    return document.location.search.substring(1).split('&').reduce(function(p,c) {
										        var parts = c.split('=', 2).map(function(param) { return decodeURIComponent(param); });
										        if(parts.length == 0 || parts[0] != param) return (p instanceof Array) && !asArray ? null : p;
										        return asArray ? p.concat(parts.concat(true)[1]) : parts.concat(true)[1];
										    }, []);
										}
										
										$("#btn-login").click(function(){
									   //Inoltro della richiesta
										$.ajax({ 
											     type:"POST",//mettendo post non visualizzo i parmatri nell'url
											     url:"ControlloLogin.jsp",
											     data:{
											    	    //Dati che vengono passati con l'inoltro della richiesta
											    	    email:$('input[name="username"]').val(),//alternativamente potrei fare  pasw:$('#login-password').val()
											    	    pasw:$('input[name="password"]').val()  //alternativamente potrei fare  pasw:$('#login-password').val()

											   	       },  
											   	
											     success:function(data){   //data sono i dati passati dalla pagina jsp invocata
												     //Inserisco la risposta del server - <input type="hidden" id="error" value="<%=error%>" />- 
												     //nel div con id =errore
											    	 $("#errore").html(data);
											    	 
											    	//Contorollo che la richiesta non abbia generato un errore 
											    	//(ciò viene fatto controllando che la pagina jsp ControllaLogin 
											    	// non abbia generato un div il cui campo vaule è settato a FALSE
											    	// - <input type="hidden" id="error" value="<%=error%>" /-) 
											    	
											    	 if($("#error").val())
											    		alert("Utente o password errati");
											    	 
											    	 //L'utente ha inserito credenziali valide.
											    	 else
											    	 {
											    	  $("#user").html("Benvenuto "+ estraiCookie("nome")+" !"); 
												      $("#logout").html("logout");
												      $("#pagina_personale").html("<a href=PaginaPersonale.html>"+"pagina personale</a>");
												      if(getURIParameter("l")==1)
												      	window.location="CreazioneOrdine.jsp";
												      else
												    	window.location="indexBoot.html";
											    	 }
											    		 		    
											     }
											})
										})
                                      </script>
										</div>
									</div>
									
<!--////////////////////////// Risposta del Server ////////////////////////  -->									
									<div id="errore" ></div>
<!--///////////////////// Fine Risposta del Server ////////////////////////  -->

									<div class="form-group">
										<div class="col-md-12 control">
											<div
												style="border-top: 1px solid #888; padding-top: 15px; font-size: 90%">
												Crea un account! <a href="#"
													onClick="$('#loginbox').hide(); $('#signupbox').show()">
													Registrati! </a>
											</div>
										</div>
									</div>

								</form>



							</div>
						</div>
					</div>
					<div id="signupbox" style="display: none; margin-top: 50px"
						class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
						<!-- <div class="panel panel-info">-->
						<div class="panel-heading">
							<!--<div class="panel-title">Sign Up</div>-->
							<!-- <div style="float:right; font-size: 85%; position: relative; top:-10px"><a id="signinlink" href="#" onclick="$('#signupbox').hide(); $('#loginbox').show()">Sign In</a></div>
                        </div>  -->


							<form method="post" name="modulo" id="signupform">
								<div class="container">
									<div class="row">
										<div class="col-md-5  toppad  pull-right col-md-offset-3 ">

											<p class=" text-info"></p>
										</div>
										<div
											class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xs-offset-0 col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad">


											<div class="panel panel-info">
												<div class="panel-heading">
													<h3 class="panel-title">
														Modulo di registrazione
														<div
															style="float: right; font-size: 80%; position: relative;">
															<script>
																Data();
															</script>
														</div>
													</h3>

												</div>
												<div class="panel-body">
													<div class="row">
														<div class="col-md-3 col-lg-3 " align="center">
															<img alt="User Pic"
																src="UserLogo.png"
																class="img-circle">
														</div>

														<div class=" col-md-9 col-lg-9 ">
															<table class="table table-user-information">
																<tbody>

																	<tr>
																		<td>Nome:</td>
																		<td><input type="text" name="nome"></td>
																	</tr>
																	<tr>
																		<td>Cognome:</td>
																		<td><input type="text" name="cognome"></td>
																	</tr>
																	<tr>
																		<td>Password:</td>
																		<td><input type="password" name="password"></td>
																	</tr>

																	<tr>
																		<td>Conferma password:</td>
																		<td><input type="password" name="conferma"></td>
																	</tr>
																	<tr>
																		<td>Data di nascita (gg/mm/aaaa):</td>
																		<td><input type="text" name="nascita"></td>
																	</tr>

																	<tr>
																		<td>Citt&agrave;:</td>
																		<td><select name="citta">
																				<option>-Seleziona-</option>
																				<script>
																					MenuCitta();
																				</script>
																		</select></td>
																	</tr>

																	<tr>
																		<td>CAP:</td>
																		<td><input type="text" name="cap"></td>
																	</tr>

																	<tr>
																		<td>Indirizzo:</td>
																		<td><input type="text" name="indirizzo"></td>
																	</tr>

																	<tr>
																		<td>Telefono (senza spazi ne simboli):</td>
																		<td><input type="text" name="telefono"></td>
																	</tr>

																	<tr>
																		<td>EMail:</td>
																		<td><input type="text" name="email" id="email"></td>
																	</tr>



																</tbody>
															</table>


														</div>
													</div>
												</div>
												<div class="panel-footer">
													<a data-original-title="Broadcast Message"
														data-toggle="tooltip" type="button"
														class="btn btn-sm btn-primary"
														href="mailto:lcalomeni@gmail.com"> Per problemi
														contattaci <i class="glyphicon glyphicon-envelope"></i>
													</a>
													<div
														style="float: right; font-size: 80%; position: relative;">
														<address>
															<a href="#" class="btn btn-primary" onClick="Registazione()">Conferma</a>

														</address>
													</div>
												</div>

											</div>
										</div>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- JS -->
	<!-- <script src="//code.jquery.com/jquery.js"></script>-->

	<script src="../js/bootstrap.min.js"></script>
	<!-- JS -->
</body>
</html>